package com.glsc.ngateway.common.base.repo.mysql.opmanage.report.regulatory;

import com.alibaba.fastjson.JSONObject;
import com.glsc.ngateway.common.base.domain.mysql.opmanage.report.regulatory.RegRptCheckRulesResult;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.math.BigInteger;
import java.util.List;

/**
 * @author: qiyr
 * @date: 2022/7/5 10:09
 * @description: 监管报表校验规则结果数据访问层
 */
@Repository
public interface RegRptCheckRulesResultRepo extends JpaRepository<RegRptCheckRulesResult, BigInteger>, JpaSpecificationExecutor<RegRptCheckRulesResult> {

    @Query(value = "select" +
            "           trrcr.id," +
            "           trrcr.rule_define_id," +
            "           trrcd.rule_name," +
            "           trrcr.status," +
            "           trrcd.rule_desc," +
            "           trrcr.create_time," +
            "           trrcr.operator," +
            "           trrcr.msg" +
            "       from" +
            "           glsc_data.t_reg_rpt_checkrules_result trrcr" +
            "       join glsc_data.t_reg_rpt_checkrules_define trrcd on" +
            "           trrcr.rule_define_id = trrcd.id" +
            "       where" +
            "           trrcd.rpt_define_id = :id" +
            "           and trrcr.bizdate = :bizdate" +
            "           and  trrcr.is_del = 0", nativeQuery = true)
    List<JSONObject> getResultDtoList(@Param("id") BigInteger id, @Param("bizdate") String bizdate);
}
